package com.mm.controller;


import com.mm.service.TestService;
import com.mm.utils.ResponseBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/Test")
public class TestController {
    @Autowired
    TestService service;

    @RequestMapping("/getList")
    public ResponseBean getList(@RequestParam Map map){
        Map resMap = service.getList(map);
        return new ResponseBean(200,"ok",resMap);
    }

    @RequestMapping("Save")
    public ResponseBean insertList(@RequestBody Map map){
        try{

            service.insertList(map);
            return  new ResponseBean(200, "succcess", true);
        }catch (Exception e){
            return  new ResponseBean(200, e.toString(), false);
        }
    }
    @GetMapping("/Delete")
    public ResponseBean delete(@RequestParam Map map){
        try{
            service.delete(map);
            return  new ResponseBean(200, "succcess", true);
        }catch (Exception e){
            return  new ResponseBean(201, e.toString(), false);
        }
    }

}
